[Relax] Allow softmax to work on a large tensor when dimension is not the last one#17720
Closed
hugolatendresse wants to merge 7 commits into
Closed
[Relax] Allow softmax to work on a large tensor when dimension is not the last one#17720hugolatendresse wants to merge 7 commits into
hugolatendresse wants to merge 7 commits into
Conversation
Member
|
let us instead to work and allow dlight to work correctly for non-last dimension cases |
Contributor
Author
Sounds good, closing the PR |
Contributor
|
Fixed in #17754 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For large tensors with non-last dimension softmax, we transpose to move the softmax dimension to the end, apply softmax, and then transpose back to the original shape.
Since the issue here that using softmax on non-last dimension could cause python/tvm/dlight/gpu/general_reduction.py to create arrays that are too big for the GPU shared memory, I tried to address this TODO by making changes to general_reduction.py, without success. However, as I was experimenting, I added a suggested handling for the case where num_leading_s = 0 in general_reduction.py. I thought I might as well leave that in the PR.
cc: @MasterJH5574
Edit: we may not merge this at all because it's better to fix the reduction directly, and the fix in this PR may simply be extra overhead